package com.heima.common.exception;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author feng js
 */

@RestControllerAdvice
@Log4j2
public class ExceptionCatch {
    @ExceptionHandler(Exception.class)
    public ResponseResult exception(Exception e) {
        log.error("catch-exception{}"+e);
        e.printStackTrace();
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }
    @ExceptionHandler(CostomException.class)
    public ResponseResult exception(CostomException e) {
        e.printStackTrace();
        log.error("catch-exception{}"+e);

        return e.getResponseResult();
    }

}
